Docly Developers
Knowledge base Bug Active

downloadBytes ignores headers set with setHeader

In shortA response sent with docly.downloadBytes does not include headers set earlier with docly.setHeader - Cache-Control, Last-Modified and similar are missing. The same headers do appear on an ordinary JSON response from the same script. Files served this way are therefore not cached by the browser.
Applies to API scriptsFilesCaching
  1. What you'll see

    You serve images or files from an API script - for example thumbnails behind access control - and set Cache-Control so the browser keeps them. Every page view downloads and scales them again.

  2. What's actually happening

    Measured 2026-11-28: docly.setHeader("Cache-Control", "private, max-age=86400") followed by return docly.downloadBytes(...) returned the file without the header. The same setHeader call followed by an ordinary object return produced the header on the JSON response.

  3. What to do

    Until this is resolved, do not rely on browser caching for files served with downloadBytes:

    • Put a version in the URL (for example ?v=<LastModified ticks>), so that a changed file always gets a new address.
    • Keep such endpoints for files that are small or rarely viewed. For many or large files, store a ready-made derivative instead of producing it on every request.

Last reviewed 28 Nov 2026